home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
ms.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
5KB
|
189 lines
/*
* EKED-M1 : Editor for Korg M1 synth; ms.c : multisound & drum sound windows
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <gemfast.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
static BYTE sample[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 33, 33,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 99, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 30, 0, 0, 0,
0, 0, 0, 99, 99, 99, 99, 99, 30, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0
};
static int point_size = 8;
static int ms_handle = -1;
static ms_rows = 20;
static int ms_selected;
static char *ms_content(int x, int y, long usr_val);
static int ms_action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val);
void ms_size(int size)
{
point_size = size;
}
void ms_window()
{
if(ms_handle < 0){
ms_handle = lm_open((GRECT *) NULL, "Multisounds",
5, ms_rows, point_size, 1 + point_size / 4,
13, point_size, WHITE, GREEN,
ms_content, ms_action, 0L);
if(ms_handle < 0)
fm_alert(1, ms_handle == OUT_OF_MEMORY ? WINDMEM_ALERT : WINDOW_ALERT);
ms_selected = NIL;
}
else
wm_topped(ms_handle);
}
static char *ms_content(int x, int y, long usr_val)
{
int n = ms_rows * x + y;
static char text[15];
text[0] = (n == ms_selected);
text[1] = '0' + n / 10;
text[2] = '0' + n % 10;
text[3] = ' ';
(void) korg2str(text + 4, multisound[n], (size_t) 10);
return text;
}
static int ms_action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val)
{
int s, t;
CLICK *c;
switch(type){
case E_CLEANUP:
m1_ctrl(handle, EXITING, 0, 0, (BYTE *) NULL);
ms_handle = -1;
break;
case E_USER:
if(((int *) event)[0] == M1_CTRL_LOST){
t = ms_selected;
if(t != NIL){
ms_selected = NIL;
lm_update(handle, t / ms_rows, t % ms_rows);
}
}
break;
case E_CLICK:
c = (CLICK *) event;
s = ms_rows * c->m_x + c->m_y;
if(s != ms_selected){
t = ms_selected;
ms_selected = s;
if(t != NIL)
lm_update(handle, t / ms_rows, t % ms_rows);
lm_update(handle, c->m_x, c->m_y);
strncpy(sample, multisound[s], (size_t) 10);
sample[12] = s;
m1_ctrl(handle, FORCE_NR | FORCE_DATA, PROG_MODE,
(s < 100) ? s : 0, sample);
}
break;
}
return R_NORMAL;
}
static int ds_handle = -1;
static ds_rows = 11;
static int ds_selected;
static char *ds_content(int x, int y, long usr_val);
static int ds_action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val);
void ds_window()
{
if(ds_handle < 0){
ds_handle = lm_open((GRECT *) NULL, "Drum Sounds",
4, ds_rows, point_size, 1 + point_size / 4,
13, point_size, WHITE, MAGENTA,
ds_content, ds_action, 0L);
if(ds_handle < 0)
fm_alert(1, ds_handle == OUT_OF_MEMORY ? WINDMEM_ALERT : WINDOW_ALERT);
ds_selected = NIL;
}
else
wm_topped(ds_handle);
}
static char *ds_content(int x, int y, long usr_val)
{
int n = 1 + ds_rows * x + y;
static char text[15];
text[0] = (n == ds_selected);
text[1] = '0' + n / 10;
text[2] = '0' + n % 10;
text[3] = ' ';
(void) korg2str(text + 4, drum_sound[n], (size_t) 10);
return text;
}
static int ds_action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val)
{
int s, t;
CLICK *c;
switch(type){
case E_CLEANUP:
ds_handle = -1;
break;
case E_CLICK:
c = (CLICK *) event;
s = ds_rows * c->m_x + c->m_y;
if(s != ds_selected){
t = ds_selected;
ds_selected = s;
if(t != NIL)
lm_update(handle, t / ds_rows, t % ds_rows);
lm_update(handle, c->m_x, c->m_y);
}
break;
}
return R_NORMAL;
}